<template>
  <div class="module-box">
    <div v-for="(item, index) in data.children" :key="index" :class="{'active-module': item.name === activeModule}" class="module-item" @click="handleClick(item)">{{ item.label }}</div>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      default() {
        return {};
      }
    },
    activeModule: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleClick(e) {
      this.$emit('moduleClick', e.name);
    }
  }
};
</script>

<style lang="scss" scoped>
.module-box {
  display: flex;
  margin: 12px 0 8px;
  @include scrollBar($x:auto, $y:hidden, $width: 2px);
  padding-bottom: 5px;
  .module-item {
    margin: 0 8px 0px 0;
    padding: 4px 8px;
    font-size: 12px;
    color: #333;
    background: #edeef2;
    border-radius: 4px;
    white-space: nowrap;
  }
  .active-module {
    color: #406eff;
  }
}
</style>
